﻿using Acme.BookStore.AcmeModel;
using Acme.BookStore.Puser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Acme.BookStore
{
    /// <summary>
    /// 操作员
    /// </summary>
    public class PuserServer :
        CrudAppService<
            PuserInfo, //The Book entity
            PuserInfoDto, //Used to show books
            Guid, //Primary key of the book entity
            PagedAndSortedResultRequestDto, //Used for paging/sorting
            PuserInfos>, //Used to create/update a book
        IPuserInfo //implement the IBookAppService
    {
        public IRepository<PuserInfo, Guid> _Puser;
        public IRepository<ProleInfo, Guid> _Prole;
        public IRepository<CompanyInfo, Guid> _Company;
        public IRepository<EnumInfo, Guid> _Enum;
        public PuserServer(IRepository<PuserInfo, Guid> Puser,IRepository<ProleInfo, Guid> Prole, IRepository<CompanyInfo, Guid> Company, IRepository<EnumInfo, Guid> Enum)
            : base(Puser)
        {
            _Puser = Puser;
            _Prole = Prole;
            _Company = Company;
            _Enum = Enum;
        }
        public List<PuserInfos> GetShow()
        {
            var str = (from a in _Puser
                       join b in _Company
                       on a.UserCompany equals b.Id.ToString()
                       join c in _Prole
                       on a.UserRoleName equals c.Id.ToString()
                       join d in _Enum
                       on a.EnmuYid equals d.Id.ToString()
                       select new PuserInfos
                       {
                           UserNumber = a.UserNumber,
                           UserUser = a.UserUser,
                           UserPwd = a.UserPwd,
                           UserName = a.UserName,
                           UserCompany = a.UserCompany,
                           UserPhone = a.UserPhone,
                           UserRoleName = a.UserRoleName,
                           UserTime = a.UserTime,
                           EnmuYid = a.EnmuYid,
                           BusyType = d.BusyType,
                           CompanyName = b.CompanyName,
                           RoleName = c.RoleName,
                       }).ToList();
            return str;
        }
    }
}
